﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using SystemHYS.API.Application.command.GualityProjectCommand;
using SystemHYS.Infrstructre.Interface;
namespace SystemHYS.API.Application.commandler.GualityProjectCommandler
{
    public class GualityProjectCreateCommandler: IRequestHandler<GualityProjectCreateCommand, int>
    {
        IGualityProjectRepository GroupRepository;
        public GualityProjectCreateCommandler(IGualityProjectRepository GroupRepository)
        {
            this.GroupRepository = GroupRepository;
        }

        public async Task<int> Handle(GualityProjectCreateCommand request, CancellationToken cancellationToken)
        {
            return await GroupRepository.AddAsyn(new Domian.GualityProject()
            {
                gualityProjectName=request.gualityProjectName,
                gualityProjectNumbering=request.gualityProjectNumbering,
                gualityProjectTool=request.gualityProjectTool,
                gualityProjectMethod=request.gualityProjectMethod,
                gualityProjectType = request.gualityProjectType,
                gualityProjectStandardValue= request.gualityProjectStandardValue,
                gualityProjectRemark= request.gualityProjectRemark,
                gualityProjectAboveDifference=0,
                gualityProjectUnderDifference=0,
                AddName = "李明",
                AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).ToUniversalTime()
            });
        }
    }
}
